dependency:
	metacity	-> libcm
	libcm (scene)   -> ws

Important thing:
	you can add XID's/windows to the scene graph. Once you do that,
	the bits will
		- automatically update
		- stay around until you explicitly remove the window 
		  again.
		- not even the destruction of the window on the server
		  will make the bits go away.
	If a destroyed or non-existant window is added, the window will
	behave as if the pixels are transparent. 

window system
	windows
		"damage"
		redirect
		unredirect
	begin/end/gl/swapbuffers
	list all windows/subwindows
	screen
	"new window"
	"map notify"
	"get_ws_window (xid)"
	name_pixmap()
	pixmap_unref()

	sync_counter

	local windows are refcounted
	"get_blah" does not increase refcount
	local windows can exist even when a remote one doesn't


above window system:

	"window_is_pretty (window, pixmap)"
		a new pixmap is now available,
		it is reasonably pretty while the signal
		is being emitted. 

	"window changed (window, pixmap, region)"
		the window has changed 

	"new window"


scene graph
	retained mode
	operates on textures and polygons
	draws using gl
	does not know anything about windows.
	just has a glwindow and a display.
	

compositing manager
	redirect all windows
	create a gl window,
	create a scene graph for the window

	"get_scene_graph()"

	

	create live texture for window


Inside window manager:

Create Scene Graph():
	sg_new()			/* will result in a number of
						sg_map_notify()
					*/

on_move_window (Window, int dx, int dy)
{
	window_list_vertices();

	wobble (vertices);
}

on_resize (Window window)
{
	freeze (window);

	resize_window();

	wait_for_app();

	thaw (window);

	/* at this point the window should be completely updated, with
	 * new pixmap and all
	 */

	<update vertices as appropriate - possibly by wobbling them
	 towards the new position>
}

on_minimize (Window window)
{
	start_genie_animation();

	when finished:
		unmap window()
}

on_sg_map_notify (Window *window)
{
	v1 = create_vertex ()
	v2 = create_vertex ()
	v3 = create_vertex ()
	v4 = create_vertex ()

	add_window (v1, v2, v3, v4, window);
}

on_sg_unmap_notify (Window *window)
{
	vertices = window_list_vertices();
	
	for (v in vertices)
		set_alpha (v, fade);

	remove_window (window);
}


Old scene graph notes:


- Graph at the vertex level
- Ability to modify vertices
- modifying vertex: invalidate screen projection of all triangles
  that touch them
- vertex can be mapped to a point on a texture.
	- system detects if it doesn't make sense
- view can display one or more scene graphs and display it

Prior art:
	- Quesa
	- java3d, doesn't work with gcj

depth buffering:
	Mixing 2D and 3D drawing does not work very well. If two 2D 
	drawings in the same plane are both depth buffered, there is
	no telling what will happen. Imprecisions will cause them to
	be rendered garbled on top of each other. 

	For 2D drawing the depth buffer doesn't work. Texture caching
	might be the way forward.

	for 2D drawing, the depth buffer is inconvenient. However
	for drawing 2D stuff on the face of a cube, we need it.
	The solution might be:
		- generally turn off depth buffering
		- 3D objects will 
			- turn on depth testing
			- turn off depth updating
			- for each child:
			-    do transformation
			-    render child
			- turn on depth buffering
			- turn off framebuffer updating
			- re-render the children

	possibility:
		turn on depth testing
		turn off depth updating
		draw child
		turn on depth updating
		turn off screen updating
		draw child

	works for a single 2d item, but not for 2d items with
	2d children (the next 2d thing will see the depth buffer
	that was updated by the previous 2d child).


	another possibility:
		make rendering explicityly two pass:
			render:
				render yourself
			update_depth buffer:
				update depth buffer for you
				and your children.
